package edu.java.homework.hw08.ipj10.exer01done;

public class MusicAlbum {

    // --- Instance Variables --------------------------------------------------
    private static final int MIN_YEAR = 1920;
    private String performer = null;
    private int year = 0;
    private double price = 0.0d;

    // --- Constructors --------------------------------------------------------

    public MusicAlbum(String performer, int year, double price) {
	setPerformer(performer);
	setYear(year);
	setPrice(price);
    }

    // --- Getters and Setters -------------------------------------------------

    public String getPerformer() {
	return performer;
    }

    public void setPerformer(String performer) {
	if (performer == null) {
	    throw new IllegalArgumentException("Null-pointed string");
	}
	this.performer = performer;
    }

    public int getYear() {
	return year;
    }

    public void setYear(int year) {
	if (year < MusicAlbum.MIN_YEAR) {
	    throw new IllegalArgumentException("Incorrect year of creation");
	}
	this.year = year;
    }

    public double getPrice() {
	return price;
    }

    public void setPrice(double price) {
	if (price < 0) {
	    throw new IllegalArgumentException(
		    "Incorrect price. Price can't be negative");
	}
	this.price = price;
    }

    // --- Methods -------------------------------------------------------------

    @Override
    public String toString() {
	StringBuilder sb = new StringBuilder();
	sb.append("Performer: " + getPerformer() + "\t");
	sb.append("Year: " + getYear() + "\t");
	sb.append("Price: " + getPrice());

	return sb.toString();
    }
}
